home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / boot / netBoot / sun3src / space.s < prev    next >
Encoding:
Text File  |  1988-05-13  |  9.4 KB  |  293 lines

  1. |
  2. |    @(#)space.s 1.1 86/09/27
  3. |    Copyright (c) 1985 by Sun Microsystems, Inc.
  4. |    space.s -- the final frontier.
  5. |
  6. |    This module provides access from 'C' to the movs instruction
  7. |    on the 68010/20.  It could be provided with an asm.sed script but
  8. |    those don't always work and are horrible.
  9. |
  10. |    Better actual idea is to change the 'C' optimizer to do this
  11. |    if you feed it a flag.
  12. |
  13. |    We save and restore the function code control registers since
  14. |    we might be getting called from an interrupt routine, and don't
  15. |    want to either (1) force interrupt routines to save & restore
  16. |    these regs, or (2) clobber the mainline's registers.
  17. |
  18. |    The store routines also clear the associated instruction cache
  19. |    entry, to allow users to store into the instruction stream using
  20. |    Monitor commands (and to allow the breakpoint command to work).
  21. |
  22.  
  23. #include "../sun3/assym.h"
  24. #include "../h/cache.h"
  25.  
  26.     .globl    _getsb, _getsw, _getsl
  27.     .globl    _putsb, _putsw, _putsl
  28.     .globl    _cache_dei, _vac_ctxflush
  29.     .globl    _vac_pageflush,_vac_segflush
  30.     .globl    _vac_flush_all
  31.  
  32.  
  33. _getsb:    movl    sp@(8),a1    | Get space number
  34.     movc    sfc,d1        | Save old source function code
  35.     movc    a1,sfc        | Set into function code register
  36.     movl    sp@(4),a0    | Get address to touch
  37.     moveq    #0,d0        | Clear result register
  38.     movsb    a0@,d0        | Pick up a byte
  39.     movc    d1,sfc        | Restore old source function code
  40.     rts
  41.  
  42. _getsw:    movl    sp@(8),a1    | Get space number
  43.     movc    sfc,d1        | Save old source function code
  44.     movc    a1,sfc        | Set into function code register
  45.     movl    sp@(4),a0    | Get address to touch
  46.     moveq    #0,d0        | Clear result register
  47.     movsw    a0@,d0        | Pick up a word
  48.     movc    d1,sfc        | Restore old source function code
  49.     rts
  50.  
  51. _getsl:    movl    sp@(8),a1    | Get space number
  52.     movc    sfc,d1        | Save old source function code
  53.     movc    a1,sfc        | Set into function code register
  54.     movl    sp@(4),a0    | Get address to touch
  55.     movsl    a0@,d0        | Pick up a long
  56.     movc    d1,sfc        | Restore old source function code
  57.     rts
  58.  
  59. _putsb:    movl    sp@(8),a1    | Get space number
  60.     movc    dfc,d1        | Save old dest function code
  61.     movc    a1,dfc        | Set into function code register
  62.     movl    sp@(4),a0    | Get address to touch
  63.     movl    sp@(12),d0    | Get value to store
  64.     movsb    d0,a0@        | Store a byte
  65.     movc    d1,dfc        | Restore old dest function code
  66.     movc    caar,a1        | Save old caar
  67.     movc    a0,caar        | Set up to clear cache entry
  68.     movc    cacr,d1        
  69.     orb    #CACR_CLEAR_ENT,d1
  70.     movc    d1,cacr        | Do it!
  71.     movc    a1,caar        | Restore old caar
  72.     rts
  73.  
  74. _putsw:    movl    sp@(8),a1    | Get space number
  75.     movc    dfc,d1        | Save old dest function code
  76.     movc    a1,dfc        | Set into function code register
  77.     movl    sp@(4),a0    | Get address to touch
  78.     movl    sp@(12),d0    | Get value to store
  79.     movsw    d0,a0@        | Store a word
  80.     movc    d1,dfc        | Restore old dest function code
  81.     movc    caar,a1        | Save old caar
  82.     movc    a0,caar        | Set up to clear cache entry
  83.     movc    cacr,d1        
  84.     orb    #CACR_CLEAR_ENT,d1
  85.     movc    d1,cacr        | Do it!
  86.     movc    a1,caar        | Restore old caar
  87.     rts
  88.  
  89. _putsl:    movl    sp@(8),a1    | Get space number
  90.     movc    dfc,d1        | Save old dest function code
  91.     movc    a1,dfc        | Set into function code register
  92.     movl    sp@(4),a0    | Get address to touch
  93.     movl    sp@(12),d0    | Get value to store
  94.     movsl    d0,a0@        | Store a long
  95.     movc    d1,dfc        | Restore old dest function code
  96.     movc    caar,a1        | Save old caar
  97.     movc    a0,caar        | Set up to clear cache entry
  98.     movc    cacr,d1        
  99.     orb    #CACR_CLEAR_ENT,d1
  100.     movc    d1,cacr        | Do it!
  101.     movc    a1,caar        | Restore old caar
  102.     rts
  103. |********************************************************
  104. | temp place for putting cache subr's
  105. | VAC (virtual Address Cache) Flush All.
  106. | We issue the flush all command VAC_FLUSH_ALL_COUNT times.
  107. | starting at virtual address 0.
  108. | We flush all valid cache data back to memory in all contexts.
  109. |
  110. | Calling function:     vac_flush_all()
  111.  
  112. _vac_flush_all:
  113.         movc    dfc,a1                  | save dfc
  114.         movl    a1,sp@-
  115.         movc    sfc,a0                  | save sfc
  116.         movl    a0,sp@-
  117.         moveq   #FC_MAP,d0
  118.         movc    d0,dfc
  119.         movc    d0,sfc
  120.         lea     VAC_FLUSH_BASE,a0       | set to flush base address
  121.         moveq   #VAC_FLUSH_ALL_COUNT,d0 | loop this many times
  122.         movb    #VAC_FLUSHALL,d1        | page flush command
  123. 10$:
  124.         movsb   d1,a0@                  | flush a set of addresses
  125.         addl    #VAC_FLUSH_INCRMNT,a0   | address of next flush
  126.         dbra    d0,10$
  127.         movsb   ENABLEOFF,d0            | read sys enable reg
  128.         bclr    #ENA_CACHE_BIT,d0
  129.         movsb   d0,ENABLEOFF            | disable the cache
  130.         jsr     _vac_init               | invalidate the cache
  131.         movl    sp@+,a0                 | restore sfc
  132.         movc    a0,sfc
  133.         movl    sp@+,a1
  134.         movc    a1,dfc                  | restore dfc
  135.         rts
  136.  
  137. |
  138. | VAC (Virtual Address Cache) Flush by context match.
  139. | We have to issue the context flush command VAC_CTXFLUSH_COUNT times.
  140. | Each time we increment the flush address by VAC_FLUSH_INCRMNT.
  141. | Context number being flushed is that stored in the context register
  142. | at the time.
  143. |
  144. | Calling function:     vac_ctxflush()
  145.  
  146. _vac_ctxflush:
  147.     movc    dfc,d3            | save current dfc
  148.     moveq    #FC_MMU,d0        | samo mmu stuff
  149.     movc    d0,dfc
  150. | now get the ctxt to flush
  151.     movl    sp@(4),d0
  152.     lea    CX_OFF,a0        | ctxt reg offset    
  153.     movsb    a0@,d2            |save current ctxt 
  154.     movsb    d0,a0@            | set it to new ctxt
  155. |
  156.         movl    #VAC_FLUSH_BASE,a0      | get flush command base address
  157.         movl    #VAC_CTXFLUSH_COUNT,d0  | loop this many times
  158.         movb    #VAC_CTXFLUSH,d1        | context flush command
  159. 10$:
  160.         movsb   d1,a0@                  | flush a set of addresses
  161.         addl    #VAC_FLUSH_INCRMNT,a0   | next address base
  162.         dbra    d0,10$                  | decrement count
  163. | restore ctxt and dfc
  164.     movc    d3,dfc
  165.     lea    CX_OFF,a0
  166.     movsb    d2,a0@
  167. | ok
  168.         rts
  169.  
  170. | VAC (virtual Address Cache) Flush by page match.
  171. | We issue the page flush command VAC_PAGEFLUSH_COUNT times.
  172. |
  173. |
  174. |
  175. | Calling function:     vac_pageflush(ctxt,vaddr)  where vaddr is virtual base
  176. |                                             address.
  177.  
  178. _vac_pageflush:
  179.         movc    dfc,d3                  | save current dfc
  180.         moveq   #FC_MMU,d0              | samo mmu stuff
  181.         movc    d0,dfc
  182. | now get the ctxt to flush
  183.         movl    sp@(4),d0
  184.         lea     CX_OFF,a0               | ctxt reg offset
  185.         movsb   a0@,d2                  |save current ctxt  
  186.         movsb   d0,a0@                  | set it to new ctxt
  187. |
  188.         movl    sp@(8),d0               | get vaddr of this page
  189.         andl    #PAGEADDRBITS,d0        | clear extraneous bits
  190.         orl     #VAC_FLUSH_BASE,d0      | set to page flush base address
  191.         movl    d0,a0
  192.         moveq   #VAC_PAGEFLUSH_COUNT,d0 | loop this many times
  193.         movb    #VAC_PAGEFLUSH,d1       | page flush command
  194. 10$:
  195.         movsb   d1,a0@                  | flush a set of addresses
  196.         addl    #VAC_FLUSH_INCRMNT,a0   | address of next page flush
  197.         dbra    d0,10$
  198. | restore ctxt and dfc
  199.         movc    d3,dfc
  200.         lea     CX_OFF,a0
  201.         movsb    d2,a0@
  202. | ok
  203.         rts
  204.  
  205. | VAC (Virtual Address Cache) flush by segment match.
  206. | We issue the segment fluish command VAC_SEGFLUSH_COUNT times.
  207. | Each time we incremtnt flush address by VAC_FLUSH_INCRMNT.
  208. |
  209. | Calling function:     vac_segflush(ctxt,segno)
  210. | u_int segno;
  211. |
  212.  
  213. _vac_segflush:
  214.         movc    dfc,d3                  | save current dfc
  215.         moveq   #FC_MMU,d0              | samo mmu stuff
  216.         movc    d0,dfc
  217. | now get the ctxt to flush
  218.         movl    sp@(4),d0
  219.         lea     CX_OFF,a0               | ctxt reg offset
  220.         movsb   a0@,d2                  |save current ctxt
  221.         movsb   d0,a0@                  | set it to new ctxt
  222. |
  223.  
  224.         movl    sp@(8),d0               | get segment number
  225.         moveq   #SGSHIFT,d1             | segment shift count
  226.         lsll    d1,d0                   | convert segment # to virt addr
  227.         orl     #VAC_FLUSH_BASE,d0      | set to set flush base addr
  228.  
  229.         movl    d0,a0
  230.         movl    #VAC_SEGFLUSH_COUNT,d0  | loop this many times
  231.         movb    #VAC_SEGFLUSH,d1        | segment flush command
  232. 10$:
  233.         movsb   d1,a0@                  | flush a set of addresses
  234.         addl    #VAC_FLUSH_INCRMNT,a0   | next address base
  235.         dbra    d0,10$
  236. | restore ctxt and dfc
  237.         movc    d3,dfc
  238.         lea     CX_OFF,a0
  239.         movsb    d2,a0@
  240. | ok
  241.         rts
  242.  
  243. | Initialize the VAC by invalidating all cache tags.
  244. | We loop thru all cache tag addresses to clear the valid bit of each
  245. | cache block.
  246. |
  247. | Calling function:     vac_init()
  248. |
  249.  
  250. _vac_init:
  251.         movl    #VAC_TAGS_BASE,a0      | (was RWTAGS)set to tag base address
  252.         movl    #VAC_RWTAG_COUNT,d0     | count for whole cache
  253.         clrl    d1
  254. 10$:
  255.         movsl   d1,a0@                  | invalid tags for a cache block
  256.         addl    #VAC_RWTAG_INCRMNT,a0   | address of next cache block
  257.         dbra    d0,10$
  258.         rts
  259.  
  260. |  do the "n" commands
  261. _cache_dei:
  262.         moveq   #FC_MMU,d0
  263.         movc    d0,sfc                  | default space
  264.         movc    d0,dfc
  265. |
  266.         movl    sp@(4),d0                | its either D  E  or I
  267.         cmpb    #0x49,d0        | is it I ?
  268.         jeq     cache_i
  269.         cmpb    #0x44,d0                 | disable?
  270.         jeq     cache_d
  271.         cmpb    #0x45,d0        | is it E nable ?
  272.         jne     cache_o                 |cant figure out
  273. cache_e:
  274.     movsb    ENABLE_REG,d0
  275.     bset    #ENA_CACHE_BIT,d0
  276.         movsb   d0,ENABLE_REG
  277.         bra     cache_o
  278. cache_d:
  279.     movsb   ENABLE_REG,d0
  280.     bclr    #ENA_CACHE_BIT,d0 
  281.         movsb   d0,ENABLE_REG
  282. | all return from here
  283. cache_o:
  284.         rts
  285. |
  286. cache_i:
  287.     jsr    _vac_init        | invalidate the cache
  288.         bra     cache_o
  289. |*************************************************
  290.  
  291.  
  292.  
  293.